package cn.edu.zut.hhr.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RestResponse {

    private boolean success;
    private Integer code;
    private String msg;
    private Object data;

    public static RestResponse success(Object data){
        return new RestResponse(true,200,"success",data);
    }

    public static RestResponse fail(Integer code, String msg, Object data){
        return new RestResponse(false,code,msg,data);
    }

    public static RestResponse fail(Integer code, String msg){
        return fail(code,msg,null);
    }

    public static RestResponse fail(Integer code){
        return fail(code,"fail",null);
    }

    public static RestResponse fail(String msg){
        return fail(500,msg,null);
    }

    public static RestResponse fail(){
        return fail(500,"fail",null);
    }

}
